package com.tangye.massageshop.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;


@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_user")
@Alias("user")
public class UserEntity extends BaseEntity{
    @TableId(type = IdType.AUTO)
    private Integer userId;
    @NotBlank
    @Size(min = 5, max = 20, message = "userName's length should be 5 ~ 20.")
    private String userName;
    @JsonIgnore
    @NotBlank
    @Size(min = 5, max = 20, message = "password's length should be 5 ~ 20.")
    private String password;
    private Integer companyId;
    private String companyName;
    private Integer shopId;
    private String shopName;
    private String role;

    public Boolean isAdmin() {
        return userName.equals("admin");
    }


}
